﻿using SqlSugar;
using System.Linq.Expressions;

namespace IBaseRepository
{
	public interface IBaseRepository<T> where T : class, new()
	{
		//增
		Task<bool> CreateAsync(T tableType);

		//删
		Task<bool> DeleteByIdAsync(int id);

		//改
		Task<bool> EditAsync(T tableType);


		//查

		/// <summary>
		/// 查询单个
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		Task<T> FindByIdAsync(int key);

		/// <summary>
		/// 查询全部
		/// </summary>
		/// <returns></returns>
		Task<List<T>> QueryAsync();

		/// <summary>
		/// 自定义条件查询
		/// </summary>
		/// <returns></returns>
		Task<List<T>> QueryAsync(Expression<Func<T,bool>> func);

		/// <summary>
		/// 分页查询
		/// </summary>
		/// <returns></returns>
		Task<List<T>> QueryAsync(int PageIndex, int PageSize, RefAsync<int> Total);

		/// <summary>
		/// 自定义分页查询
		/// </summary>
		/// <returns></returns>
		Task<List<T>> QueryAsync(Expression<Func<T, bool>> func,int PageIndex,int PageSize,RefAsync<int> Total);

	}
}
